<?php
require_once("vcl/vcl.inc.php");
require_once("lib/db_connection.php");
//Includes
use_unit("components4phpfull/jtdivwindow.inc.php");
use_unit("components4phpfull/jtgroupbox.inc.php");
use_unit("components4phpfull/jtjavascript.inc.php");
use_unit("comctrls.inc.php");
use_unit("components4phpfull/jtpdodatabase.inc.php");
use_unit("components4phpfull/jtsitetheme.inc.php");
use_unit("components4phpfull/jtpagecontrol.inc.php");
use_unit("components4phpfull/jtdatepicker.inc.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class personnel_create2 extends Page
{
       public $edLimit = null;
       public $Label10 = null;
       public $JTGroupBox3 = null;
       public $lblAddress = null;
       public $lblCity = null;
       public $edCity = null;
       public $edBldg = null;
       public $lblBldg = null;
       public $Label13 = null;
       public $cmbCountry = null;
       public $Label11 = null;
       public $lblEmail = null;
       public $btnShowDepartment = null;
       public $btnShowJob = null;
       public $lblphone2 = null;
       public $Label6 = null;
       public $edArea2 = null;
       public $Label4 = null;
       public $edPhone2 = null;
       public $lblphone1 = null;
       public $lblarea1 = null;
       public $Label3 = null;
       public $edArea1 = null;
       public $Label1 = null;
       public $edPhone1 = null;
       public $edAddress = null;
       public $lblphone = null;
       public $lblarea = null;
       public $Label9 = null;
       public $edArea = null;
       public $lblMName = null;
       public $lblem = null;
       public $lblst = null;
       public $lblm = null;
       public $lblf = null;
       public $lbll = null;
       public $lblid = null;
       public $Label16 = null;
       public $cmbMunicipality = null;
       public $Label15 = null;
       public $cmbProvince = null;
       public $Label5 = null;
       public $cmbRegion = null;
       public $dpHireDate = null;
       public $dpDateBirth = null;
       public $cmbdept = null;
       public $chkVehOp = null;
       public $Label2 = null;
       public $lblHireDate = null;
       public $lblDept = null;
       public $cmbJob = null;
       public $lblJob = null;
       public $lblBirthdate = null;
       public $edContactName2 = null;
       public $lblContact2 = null;
       public $edContactName1 = null;
       public $lblContactName1 = null;
       public $lblContact1 = null;
       public $lblPhoneNo = null;
       public $edphone = null;
       public $lblMobile = null;
       public $edMobile = null;
       public $edEmail = null;
       public $edZip = null;
       public $lblZip = null;
       public $lblLName = null;
       public $edLName = null;
       public $lblFName = null;
       public $edMName = null;
       public $edFName = null;
       public $uploadEmp = null;
       public $lblPhoto = null;
       public $edEmpId = null;
       public $lblEmpId = null;
       public $lblarea2 = null;
       public $JSProvinceMunicipality = null;
       public $JSRegionProvince = null;
       public $Label12 = null;
       public $edloc = null;
       public $lblLocation = null;
       public $JSValidate = null;
       public $hfError = null;
       public $btnClose = null;
       public $JTDivDepartment = null;
       public $JTGroupBox2 = null;
       public $btnAddDepartment = null;
       public $btnDelDepartment = null;
       public $edDepartment = null;
       public $listDepartment = null;
       public $JTDivJob = null;
       public $JTGroupBox1 = null;
       public $btnAddJob = null;
       public $btnDelJob = null;
       public $edJob = null;
       public $listJob = null;
       public $JTJavaScript6 = null;
       public $JTJavaScript5 = null;
       public $JTJavaScript4 = null;
       public $compid = null;
       public $JTJavaScript3 = null;
       public $JTJavaScript2 = null;
       public $JTJavaScript1 = null;
       public $btnSubmit = null;
       public $edDefRate = null;
       public $lblDefRate = null;
       public $Image1 = null;
       function edLimitJSKeyUp($sender, $params)
       {

       ?>
       //Add your javascript code here
       //accept only numbers
       var numero = document.getElementById("edLimit").value;
       var first = numero.indexOf('.');
       var last = numero.lastIndexOf('.');

       while(isNaN(numero))
       {
        haba = numero.length;
        haba = haba - 1;
        numero = numero.substr(0,haba);
       }

       while(first!=last)
       {
        numero = numero.slice(0,last);
        first = numero.indexOf('.');
        last = numero.lastIndexOf('.');
       }
       document.getElementById("edLimit").value = numero;
       <?php

       }


       function edCityJSBlur($sender, $params)
       {

       ?>
       //Add your javascript code here
       validateRequire('edCity','lblCity');
       <?php

       }


       function edPhone2JSBlur($sender, $params)
       {

       ?>
       //Add your javascript code here
       //validateRequire('edPhone2','lblphone2');

       var edPhone2 = document.getElementById('edPhone2').value;

       if(edPhone2.length>0)
       {
       regex_pattern = "^[0-9]{3}[-]?[0-9]{4}$";
       var reg = new RegExp(regex_pattern);
       var match = document.getElementById('edPhone2').value.match(reg);
       if(match==null)
       {
        document.getElementById('lblphone2').innerHTML = "&darr;&nbsp;Incorrect format - e.g.899-1234&nbsp;&darr;";
       }
       else
       {
        document.getElementById('lblphone2').innerHTML = "";
       }
       }
       <?php

       }

       function edArea2JSBlur($sender, $params)
       {

       ?>
       //Add your javascript code here
       var edArea2 = document.getElementById('edArea2').value;

       if(edArea2.length>0)
       {
       regex_pattern = "^[0-9]{2,4}$";
       var reg = new RegExp(regex_pattern);
       var match = document.getElementById('edArea2').value.match(reg);
       if(match==null)
       {
        document.getElementById('lblarea2').innerHTML = "Incorrect format - e.g. 02&nbsp;&darr;";
       }
       else
       {
        document.getElementById('lblarea2').innerHTML = "&nbsp;";
       }
       }
       <?php

       }

       function edPhone1JSBlur($sender, $params)
       {

       ?>
       //Add your javascript code here
       //validateRequire('edPhone1','lblphone1');

       var edPhone1 = document.getElementById('edPhone1').value;

       if(edPhone1.length>0)
       {
       regex_pattern = "^[0-9]{3}[-]?[0-9]{4}$";
       var reg = new RegExp(regex_pattern);
       var match = document.getElementById('edPhone1').value.match(reg);
       if(match==null)
       {
        document.getElementById('lblphone1').innerHTML = "&darr;&nbsp;Incorrect format - e.g.899-1234&nbsp;&darr;";
       }
       else
       {
        document.getElementById('lblphone1').innerHTML = "";
       }
       }
       <?php

       }

       function edArea1JSBlur($sender, $params)
       {

       ?>
       //Add your javascript code here
       var edArea1 = document.getElementById('edArea1').value;

       if(edArea1.length>0)
       {
       regex_pattern = "^[0-9]{2,4}$";
       var reg = new RegExp(regex_pattern);
       var match = document.getElementById('edArea1').value.match(reg);
       if(match==null)
       {
        document.getElementById('lblarea1').innerHTML = "Incorrect format - e.g. 02&nbsp;&darr;";
       }
       else
       {
        document.getElementById('lblarea1').innerHTML = "&nbsp;";
       }
       }
       <?php

       }

       function edAreaJSBlur($sender, $params)
       {

       ?>
       //Add your javascript code here
       var edArea = document.getElementById('edArea').value;
       validateRequire('edArea','lblarea');

       if(edArea.length>0)
       {
       regex_pattern = "^[0-9]{2,4}$";
       var reg = new RegExp(regex_pattern);
       var match = document.getElementById('edArea').value.match(reg);
       if(match==null)
       {
        document.getElementById('lblarea').innerHTML = "Incorrect format - e.g. 02&nbsp;&darr;";
       }
       else
       {
        document.getElementById('lblarea').innerHTML = "&nbsp;";
       }
       }
       <?php

       }


       function personnel_createJSLoad($sender, $params)
       {
       $this->clr_start();
       ?>
       //Add your javascript code here

       <?php

       }



       function edEmailJSBlur($sender, $params)
       {

       ?>
       //Add your javascript code here
       //validateRequire('edEmail','lblem');

       var edEmail = document.getElementById('edEmail').value;

       if(edEmail.length>0)
       {
       regex_pattern = "[A-Za-z0-9_\.]+[@][A-Za-z-]+[.][A-Za-z]{2,4}([\.A-Za-z]{2,3})?$";
       var regm = new RegExp(regex_pattern);
       var match = document.getElementById('edEmail').value.match(regm);
       if(match==null)
       {
        document.getElementById('lblem').innerHTML = "&darr;&nbsp;Incorrect format - e.g.(user@mail.com)&nbsp;&darr;";
       }
       else
       {
        document.getElementById('lblem').innerHTML = "";
       }
       }
       <?php

       }

       function edphoneJSBlur($sender, $params)
       {

       ?>
       //Add your javascript code here
        validateRequire('edphone','lblphone');

       var edphone = document.getElementById('edphone').value;

       if(edphone.length>0)
       {
       regex_pattern = "^[0-9]{3}[-]?[0-9]{4}$";
       var reg = new RegExp(regex_pattern);
       var match = document.getElementById('edphone').value.match(reg);
       if(match==null)
       {
        document.getElementById('lblphone').innerHTML = "&darr;&nbsp;Incorrect format - e.g.899-1234&nbsp;&darr;";
       }
       else
       {
        document.getElementById('lblphone').innerHTML = "";
       }
       }
       <?php

       }

      function edAddressJSBlur($sender, $params)
       {

       ?>
       //Add your javascript code here
       validateRequire('edAddress','lblst');;
       <?php

       }

       function edMNameJSBlur($sender, $params)
       {

       ?>
       //Add your javascript code here
       validateRequire('edMName','lblm');
       <?php

       }

       function edFNameJSBlur($sender, $params)
       {

       ?>
       //Add your javascript code here
       validateRequire('edFName','lblf');
       <?php

       }


       function edLNameJSBlur($sender, $params)
       {

       ?>
       //Add your javascript code here
       validateRequire('edLName','lbll');
       <?php

       }

       function edEmpIdJSBlur($sender, $params)
       {

       ?>
       //Add your javascript code here
       validateRequire('edEmpId','lblid');
       <?php

       }




       function btnCloseJSClick($sender, $params)
       {

       ?>
       window.close();

       <?php

       }

       function personnel_create2JSLoad($sender, $params)
       {
       $this->clr_start();
       ?>
       //Add your javascript code here

       <?php

       }


       function btnDelDepartmentJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       var DeptIndex = document.getElementById('listDepartment').selectedIndex;
       var DeptValue = document.getElementById('listDepartment')[DeptIndex].value;
       var comp = document.getElementById('compid').value;
       AjaxDept3(DeptValue,comp);
       <?php

       }

       function btnAddDepartmentJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       var adddept = document.getElementById('edDepartment').value;
       var comp = document.getElementById('compid').value;
       AjaxDept2(adddept,comp);
       document.getElementById('edDepartment').value = "";
       <?php

       }

       function btnShowDepartmentJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.getElementById('JTDivDepartment').Show();
       document.getElementById('edDepartment').value = "";
       <?php

       }



       function btnDelJobJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       var JobIndex = document.getElementById('listJob').selectedIndex;
       var JobValue = document.getElementById('listJob')[JobIndex].value;
       var comp = document.getElementById('compid').value;
       AjaxJob3(JobValue,comp);
       <?php

       }

       function btnAddJobJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       var addjob = document.getElementById('edJob').value;
       var comp = document.getElementById('compid').value;
       AjaxJob2(addjob,comp);
       document.getElementById('edJob').value = "";

       <?php

       }

       function btnShowJobJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.getElementById('JTDivJob').Show();
          document.getElementById('edJob').value = "";
       <?php

       }


       function cmbProvinceJSChange($sender, $params)
       {
       //echo $this->cmbProvince->ajaxCall("VendorProvinceChange");
       ?>
       provinceMunicipality();
       return false;

       <?php

       }

       function cmbRegionJSChange($sender, $params)
       {
       //echo $this->cmbRegion->ajaxCall('VendorRegionChange');
       ?>
       regionProvince();
       return false;
       <?php

       }

       function btnCancelClick($sender, $params)
       {
       redirect('personnel_list.php?company_id='.$_SESSION['company_id']);


       }



       function VendorRegionChange()
       {
       $region_id = $this->cmbRegion->getItemIndex();
       $this->cmbProvince->Clear();
       $this->cmbProvince->AddItem('--Select--', null, null);
       $result_province = mysql_query("select * from lookup_province where region_id='".$region_id."'");

       while($row_province = mysql_fetch_array($result_province))
       {
            $this->cmbProvince->AddItem($row_province['province'], null, $row_province['id']);
       }

       if($region_id==0)
       {
        $this->cmbProvince->Clear();
        $this->cmbMunicipality->Clear();
        $this->cmbProvince->AddItem('--Select Region First--',null,null);
        $this->cmbMunicipality->AddItem('--Select Province First--',null,null);
       }
       }



       function VendorProvinceChange()
       {

       $region_id = $this->cmbRegion->getItemIndex();
       $this->cmbProvince->Clear();
       $this->cmbProvince->AddItem('--Select--', null, null);
       $result_province = mysql_query("select * from lookup_province where region_id='".$region_id."'");

       while($row_province = mysql_fetch_array($result_province))
       {
            $this->cmbProvince->AddItem($row_province['province'], null, $row_province['id']);
       }

       $province_id = $this->cmbProvince->getItemIndex();
       $this->cmbMunicipality->Clear();
       $this->cmbMunicipality->AddItem('--Select--', null, null);
       $result_municipality = mysql_query("select * from lookup_municipality where province_id='".$province_id."'");

       while($row_municipality = mysql_fetch_array($result_municipality))
       {
            $this->cmbMunicipality->AddItem($row_municipality['municipality'], null, $row_municipality['id']);
       }

       if($province_id==0)
       {
        $this->cmbMunicipality->Clear();
        $this->cmbMunicipality->AddItem('--Select Province First--',null,null);
       }
       }

       function clr_start()
       {
       $this->edEmpId->Text = '';
       $this->edLName->Text = '';
       $this->edFName->Text = '';
       $this->edMName->Text = '';
       $this->edAddress->Text = '';
       $this->edBldg->Text = '';
       $this->edZip->Text = '';
       $this->edEmail->Text = '';
       $this->edphone->Text = '';
       $this->edArea->Text = '';
       $this->edMobile->Text = '';
       $this->edContactName1->Text = '';
       $this->edPhone1->Text = '';
       $this->edContactName2->Text = '';
       $this->edPhone2->Text = '';
       $this->edArea1->Text = '';
       $this->edArea2->Text = '';
       $this->edloc->Text = '';
       $this->dpHireDate->Text = '';
       $this->dpDateBirth->Text = '';
       $this->edLimit->Text='';
       $this->edCity->Text = '';
       //$this->uploadEmp->FileExt = '';

       //Vendor Region,Prov, Municipality

       $this->cmbRegion->Clear();
       $this->cmbRegion->AddItem('--Select--', null, null);
       $this->cmbRegion->setItemIndex('--Select--');
       $result_vend_region = mysql_query("select * from lookup_region");

        while($row_vend_region = mysql_fetch_array($result_vend_region))
        {
            $this->cmbRegion->AddItem($row_vend_region['region'], null, $row_vend_region['id']);
        }

        $this->cmbProvince->Clear();
        $this->cmbMunicipality->Clear();
        $this->cmbProvince->AddItem('--Select Region First--',null,null);
        $this->cmbMunicipality->AddItem('--Select Province First--',null,null);


       $this->cmbdept->Clear();
       $this->cmbdept->AddItem('--Select--', null, null);
       $this->cmbdept->setItemIndex('--Select--', null, null);
       $result_dept = mysql_query("select * from lookup_personnel_tbl where company_id='".$_SESSION['company_id']."' AND category='departments'");

        while($row_dept = mysql_fetch_array($result_dept))
        {
            $this->cmbdept->AddItem($row_dept['value'], null, $row_dept['value']);
        }

        $this->compid->Value = $_SESSION['company_id'];
        $this->cmbJob->Clear();
        $this->cmbJob->AddItem('--Select--', null, null);
        $this->cmbJob->setItemIndex('--Select--', null, null);
        $result_job = mysql_query("select * from lookup_personnel_tbl where company_id='".$_SESSION['company_id']."' AND category='job titles'");

        while($row_job = mysql_fetch_array($result_job))
        {
            $this->cmbJob->AddItem($row_job['value'], null, $row_job['value']);
        }
       }


       function validateRequired($value, $lbl)
       {
          if($value == '' || $value == null)
          {
             $this->$lbl->Caption = '&darr; This field is required &darr;';
             $this->hfError->setValue('1');
          }
       }

       function personnel_create2Create($sender, $params)
       {
       $this->clr_start();

       $this->hfError->setValue('0');
       $this->lblphone->Caption = '';
       $this->lblarea->Caption = '';
       $this->lblem->Caption = '';
       $this->lblst->Caption = '';
       $this->lblid->Caption = '';
       $this->lblf->Caption = '';
       $this->lblm->Caption = '';
       $this->lbll->Caption = '';
       $this->lblphone1->Caption = '';
       $this->lblphone2->Caption = '';
       $this->lblarea1->Caption = '';
       $this->lblarea2->Caption = '';
       $this->lblCity->Caption = '';
       $this->chkVehOp->Checked=false;

       $this->cmbCountry->Clear();
       $this->cmbCountry->ItemIndex = "Philippines";
        $result_country = mysql_query("select * from countries order by country ASC");

        while($row_country = mysql_fetch_array($result_country))
        {
            $this->cmbCountry->AddItem($row_country['country'], null, $row_country['country']);
        }

        $this->compid->Value = $_SESSION['company_id'];
        $this->cmbJob->Clear();
        $this->cmbJob->AddItem('--Select--', null, null);
        $result_job = mysql_query("select * from lookup_personnel_tbl where company_id='".$_SESSION['company_id']."' AND category='job titles' order by value asc");

        while($row_job = mysql_fetch_array($result_job))
        {
            $this->cmbJob->AddItem($row_job['value'], null, $row_job['value']);
        }

        //list job title
        $this->listJob->Clear();
        $result_title = mysql_query("select * from lookup_personnel_tbl where company_id='".$_SESSION['company_id']."' AND category='job titles' order by value asc");

        while($row_title = mysql_fetch_array($result_title))
        {
            $this->listJob->AddItem($row_title['value'], null, $row_title['value']);
        }


        $this->cmbdept->Clear();
        $this->cmbdept->AddItem('--Select--', null, null);
        $result_dept = mysql_query("select * from lookup_personnel_tbl where company_id='".$_SESSION['company_id']."' AND category='departments'");

        while($row_dept = mysql_fetch_array($result_dept))
        {
            $this->cmbdept->AddItem($row_dept['value'], null, $row_dept['value']);
        }

        //list department
        $this->listDepartment->Clear();
        $result_depart = mysql_query("select * from lookup_personnel_tbl where company_id='".$_SESSION['company_id']."' AND category='departments'");

        while($row_depart = mysql_fetch_array($result_depart))
        {
            $this->listDepartment->AddItem($row_depart['value'], null, $row_depart['value']);
        }


       $this->dpHireDate->Text= '';
       $this->dpDateBirth->Text = '';

       //$this->imgBack->setLink('personnel_list.php?company_id='.$_SESSION['company_id']);


       }

       function btnSubmitClick($sender, $params)
       {
       //$this->validateRequired($this->edAddress->Text, 'lblst');
       //$this->validateRequired($this->edphone->Text, 'lblph');
       //$this->validateRequired($this->edEmail->Text, 'lblem');
       $this->validateRequired($this->edEmpId->Text, 'lblid');
       $this->validateRequired($this->edFName->Text, 'lblf');
       $this->validateRequired($this->edLName->Text, 'lbll');
       //$this->validateRequired($this->edMName->Text, 'lblm');

       $phone = $this->edphone->Text;
       $this->validateRequired($phone, 'lblphone');

       $street = $this->edAddress->Text;
       $this->validateRequired($street, 'lblst');

       if($phone!='')
       {
       if(preg_match("/^[0-9]{3}[-]?[0-9]{4}$/", $phone))
       {
       $this->lblphone->Caption = '';
       }
       else
       {
       $this->lblphone->Caption = '&darr;&nbsp;Incorrect format - e.g.899-1234&nbsp;&darr;';
       $this->hfError->setValue('1');
       }
       }

       $city = $this->edCity->Text;
       $this->validateRequired($city, 'lblCity');

       $acode = $this->edArea->Text;
       $this->validateRequired($acode, 'lblarea');
       if($acode!='')
       {
       if(preg_match("/^[0-9]{2,4}$/", $acode))
       {
       $this->lblarea->Caption = '';
       }
       else
       {
       $this->lblarea->Caption = 'Incorrect format - e.g.02&nbsp;&darr;';
       $this->hfError->setValue('1');
       }
       }

       $email = $this->edEmail->Text;
       //if($email=='')
       //$this->validateRequired($this->edEmail->Text, 'lblem');

       if($email!='')
       {
       if(preg_match("/[A-Za-z0-9_\.]+[@][A-Za-z-]+[.][A-Za-z]{2,4}([\.A-Za-z]{2,3})?$/", $email))
       {
       $this->lblem->Caption = '';
       }
       else
       {
       $this->lblem->Caption = '&darr;&nbsp;Incorrect format - e.g.(user@mail.com)&nbsp;&darr;';
       $this->hfError->setValue('1');
       }
       }

       $phone1 = $this->edPhone1->Text;
       if($phone1!='')
       {
       if(preg_match("/^[0-9]{3}[-]?[0-9]{4}$/", $phone1))
       {
       $this->lblphone1->Caption = '';
       }
       else
       {
       $this->lblphone1->Caption = '&darr;&nbsp;Incorrect format - e.g.899-1234&nbsp;&darr;';
       $this->hfError->setValue('1');
       }
       }

       $phone2 = $this->edPhone2->Text;
       if($phone2!='')
       {
       if(preg_match("/^[0-9]{3}[-]?[0-9]{4}$/", $phone2))
       {
       $this->lblphone2->Caption = '';
       }
       else
       {
       $this->lblphone2->Caption = '&darr;&nbsp;Incorrect format - e.g.899-1234&nbsp;&darr;';
       $this->hfError->setValue('1');
       }
       }

       $acode1 = $this->edArea1->Text;
       if($acode1!='')
       {
       if(preg_match("/^[0-9]{2,4}$/", $acode1))
       {
       $this->lblarea1->Caption = '';
       }
       else
       {
       $this->lblarea1->Caption = 'Incorrect format - e.g.02&nbsp;&darr;';
       $this->hfError->setValue('1');
       }
       }

       $acode2 = $this->edArea2->Text;
       if($acode2!='')
       {
       if(preg_match("/^[0-9]{2,4}$/", $acode2))
       {
       $this->lblarea2->Caption = '';
       }
       else
       {
       $this->lblarea2->Caption = 'Incorrect format - e.g.02&nbsp;&darr;';
       $this->hfError->setValue('1');
       }
       }


       $error = $this->hfError->getValue();
       if($error == '1' || $number != $key)
       {
          $this->hfError->setValue('0');
          return false;
       }
       else if($error == '0')
       {



       $result_emp_id = mysql_query("SELECT MAX(autoid) as max FROM employee_tbl") or die("SELECT AUTOID - ".mysql_error());
       $row_emp_id = mysql_fetch_array($result_emp_id);
       $emp_id = $row_emp_id['max']+1;

       if($this->chkVehOp->Checked==true)
       {
       $veh_op = '1';
       }
       else
       {
       $veh_op = '0';
       }

       if($this->uploadEmp->FileExt!='')
       {
       $result = mysql_query("insert into employee_tbl (emp_id,
       company_id,
       lname,
       fname,
       mname,
       birthdate,
       bldg,
       address,
       city,
       country,
       zip,
       email,
       phone_num,
       mobile_num,
       emergency_contact1,
       contact_num1,
       emergency_contact2,
       contact_num2,
       acode,
       contact_acode1,
       contact_acode2,
       department,
       location,
       hire_date,
       job_title,
       veh_op,
       photo,
       credit_limit
       )

       values ('".$this->edEmpId->Text."',
      '".$_SESSION['company_id']."',
       '".$this->edLName->Text."',
       '".$this->edFName->Text."',
       '".$this->edMName->Text."',
       '".$this->dpDateBirth->Text."',
       '".$this->edBldg->Text."',
       '".$this->edAddress->Text."',
       '".$this->edCity->Text."',
       '".$this->cmbCountry->getItemIndex()."',
       '".$this->edZip->Text."',
       '".$this->edEmail->Text."',
       '".$this->edphone->Text."',
       '".$this->edMobile->Text."',
       '".$this->edContactName1->Text."',
       '".$this->edPhone1->Text."',
       '".$this->edContactName2->Text."',
       '".$this->edPhone2->Text."',
       '".$this->edArea->Text."',
       '".$this->edArea1->Text."',
       '".$this->edArea2->Text."',
       '".$this->cmbdept->getItemIndex()."',
       '".$this->edloc->Text."',
       '".$this->dpHireDate->Text."',
       '".$this->cmbJob->getItemIndex()."',
       '".$veh_op."',
       '"."photo/employee/emp".$emp_id.".".$this->uploadEmp->FileExt."',
       '".$this->edLimit->Text."')
       ")or die("INSERT EMPLOYEE - ".mysql_error());
       }


       if($this->uploadEmp->FileExt=='')
       {
       $result = mysql_query("insert into employee_tbl (emp_id,
       company_id,
       lname,
       fname,
       mname,
       birthdate,
       bldg,
       address,
       city,
       country,
       zip,
       email,
       phone_num,
       mobile_num,
       emergency_contact1,
       contact_num1,
       emergency_contact2,
       contact_num2,
       acode,
       contact_acode1,
       contact_acode2,
       department,
       location,
       hire_date,
       job_title,
       veh_op,
       photo,
       credit_limit
       )

       values ('".$this->edEmpId->Text."',
       '".$_SESSION['company_id']."',
       '".$this->edLName->Text."',
       '".$this->edFName->Text."',
       '".$this->edMName->Text."',
       '".$this->dpDateBirth->Text."',
       '".$this->edBldg->Text."',
       '".$this->edAddress->Text."',
       '".$this->edCity->Text."',
       '".$this->cmbCountry->getItemIndex()."',
       '".$this->edZip->Text."',
       '".$this->edEmail->Text."',
       '".$this->edphone->Text."',
       '".$this->edMobile->Text."',
       '".$this->edContactName1->Text."',
       '".$this->edPhone1->Text."',
       '".$this->edContactName2->Text."',
       '".$this->edPhone2->Text."',
       '".$this->edArea->Text."',
       '".$this->edArea1->Text."',
       '".$this->edArea2->Text."',
       '".$this->cmbdept->getItemIndex()."',
       '".$this->edloc->Text."',
       '".$this->dpHireDate->Text."',
       '".$this->cmbJob->getItemIndex()."',
       '".$veh_op."',
       'image/no_img.png',
       '".$this->edLimit->Text."')
       ")or die("INSERT EMPLOYEE - ".mysql_error());
       }


        $this->uploadEmp->moveUploadedFile("photo/employee/emp".$emp_id.".".$this->uploadEmp->FileExt);

        echo "<script type=text/javascript>
        alert('Successfully added record');
        window.opener.location.reload();
        var answer = confirm('Add another record?');
       if(answer)
       {
       window.location.href='set_personnel_create.php';
       }
       else
       {
       window.close();
       }
        //window.location.href='set_personnel_create.php';
        //window.close();
        </script>";
        //redirect('personnel_list.php?company_id='.$_SESSION['company_id']);
        $this->clr_start();
       }
       }

}

global $application;

global $personnel_create2;

//Creates the form
$personnel_create2=new personnel_create2($application);

//Read from resource file
$personnel_create2->loadResource(__FILE__);

//Shows the form
$personnel_create2->show();

?>